import Vue from 'vue'
import VueRouter from 'vue-router'

// import Login from '../components/Login.vue'
const Login = () => import(/* webpackChunkName: "login_home_welcome" */ '../components/Login.vue')
const Home = () => import(/* webpackChunkName: "login_home_welcome" */ '../components/Home.vue')
const Welcome = () => import(/* webpackChunkName: "login_home_welcome" */ '../components/Welcome.vue')

const Users = () => import(/* webpackChunkName: "users_Rights_Roles_Accounts_RoleManage" */ '../components/system/Users.vue')
const Rights = () => import(/* webpackChunkName: "users_Rights_Roles_Accounts_RoleManage" */ '../components/system/Rights.vue')
const Roles = () => import(/* webpackChunkName: "users_Rights_Roles_Accounts_RoleManage" */ '../components/system/Roles.vue')
const Accounts = () => import(/* webpackChunkName: "users_Rights_Roles_Accounts_RoleManage" */ '../components/system/Accounts.vue')
const RoleManage = () => import(/* webpackChunkName: "users_Rights_Roles_Accounts_RoleManage" */ '../components/system/RoleManage.vue')
const Logs = () => import(/* webpackChunkName: "users_Rights_Roles_Accounts_RoleManage" */ '../components/system/logs.vue')
const ParamConfig = () => import(/* webpackChunkName: "users_Rights_Roles_Accounts_RoleManage" */ '../components/system/ParamConfig.vue')

const Classification = () => import(/* webpackChunkName: "product_all" */ '../components/product/Classification.vue')
const Configure = () => import(/* webpackChunkName: "product_all" */ '../components/product/Configure.vue')
const ProductAdd = () => import(/* webpackChunkName: "product_all" */ '../components/product/ProductAdd.vue')
const ProductEdit = () => import(/* webpackChunkName: "product_all" */ '../components/product/ProductEdit.vue')
const ProductClassAdd = () => import(/* webpackChunkName: "product_all" */ '../components/product/ProductClassAdd.vue')
const ProductClassEdit = () => import(/* webpackChunkName: "product_all" */ '../components/product/ProductClassEdit.vue')
const Source = () => import(/* webpackChunkName: "product_all" */ '../components/product/Source.vue')

const SupplierProduct = () => import(/* webpackChunkName: "supplier_all" */ '../components/supplier/Product.vue')
const SupplierConfigure = () => import(/* webpackChunkName: "supplier_all" */ '../components/supplier/Configure.vue')
const SupplierProductAdd = () => import(/* webpackChunkName: "supplier_all" */ '../components/supplier/ProductAdd.vue')
const ProductDetail = () => import(/* webpackChunkName: "supplier_all" */ '../components/supplier/ProductDetail.vue')
const SupplierAdd = () => import(/* webpackChunkName: "supplier_all" */ '../components/supplier/SupplierAdd.vue')
const SupplierEdit = () => import(/* webpackChunkName: "supplier_all" */ '../components/supplier/SupplierEdit.vue')

const ConfigureList = () => import(/* webpackChunkName: "coupon_all" */ '../components/coupon/ConfigureList.vue')
const QueryList = () => import(/* webpackChunkName: "coupon_all" */ '../components/coupon/QueryList.vue')
const GrantRecordList = () => import(/* webpackChunkName: "coupon_all" */ '../components/coupon/GrantRecordList.vue')
const AddCoupon = () => import(/* webpackChunkName: "coupon_all" */ '../components/coupon/AddCoupon.vue')
const EditCoupon = () => import(/* webpackChunkName: "coupon_all" */ '../components/coupon/EditCoupon.vue')

const CommodityConfigureList = () => import(/* webpackChunkName: "commodity_all" */ '../components/commodity/ConfigureList.vue')
const CommodityOrderList = () => import(/* webpackChunkName: "commodity_all" */ '../components/commodity/OrderList.vue')
const AddCommodity = () => import(/* webpackChunkName: "commodity_all" */ '../components/commodity/AddCommodity.vue')
const CommodityDetail = () => import(/* webpackChunkName: "commodity_all" */ '../components/commodity/CommodityDetail.vue')
const CommodityOrderDetail = () => import(/* webpackChunkName: "commodity_all" */ '../components/commodity/OrderDetail.vue')
const AntiLostCardList = () => import(/* webpackChunkName: "commodity_all" */ '../components/commodity/AntiLostCardList.vue')
const AntiLostCardDetail = () => import(/* webpackChunkName: "commodity_all" */ '../components/commodity/AntiLostCardDetail.vue')

const UserPets = () => import(/* webpackChunkName: "pets_all" */ '../components/pets/UserPets.vue')
const AntiLostCodeManage = () => import(/* webpackChunkName: "pets_all" */ '../components/pets/AntiLostCodeManage.vue')
const HotSpotsManage = () => import(/* webpackChunkName: "pets_all" */ '../components/pets/HotSpotsManage.vue')
const HotSpotAdd = () => import(/* webpackChunkName: "pets_all" */ '../components/pets/HotSpotAdd.vue')
const HotSpotEdit = () => import(/* webpackChunkName: "pets_all" */ '../components/pets/HotSpotEdit.vue')

const ServicecardConfigure = () => import(/* webpackChunkName: "servicecard_all" */ '../components/servicecard/Configure.vue')
const ServicecardAdd = () => import(/* webpackChunkName: "servicecard_all" */ '../components/servicecard/ServicecardAdd.vue')
const ServicecardEdit = () => import(/* webpackChunkName: "servicecard_all" */ '../components/servicecard/ServicecardEdit.vue')
const ServicecardQueryList = () => import(/* webpackChunkName: "servicecard_all" */ '../components/servicecard/QueryList.vue')
const ServicecardGrantRecordList = () => import(/* webpackChunkName: "servicecard_all" */ '../components/servicecard/GrantRecordList.vue')

const PetHousekeeping = () => import(/* webpackChunkName: "order_all" */ '../components/order/PetHousekeeping.vue')
const PetHousekeepingDetail = () => import(/* webpackChunkName: "order_all" */ '../components/order/PetHousekeepingDetail.vue')
// 健康预约订单
const Healthkeeping = () => import(/* webpackChunkName: "order_all" */ '../components/order/HealthOrder.vue')
const HealthkeepingDetail = () => import(/* webpackChunkName: "order_all" */ '../components/order/HealthDetail.vue')

// 礼包管理
const GiftManage = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/GiftManage.vue')
const GiftDetail = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/GiftDetail.vue')
const GiftBasicInfo = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/GiftBasicInfo.vue')
const GiftRuleBasicInfo = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/GiftRuleBasicInfo.vue')
const GiftRuleEdit = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/GiftRuleEdit.vue')

const AddGift = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/AddGift.vue')
const AddGiftRule = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/AddGiftRule.vue')
const PriceRuleAdd = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/PriceRuleAdd.vue')
const PriceRuleEdit = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/PriceRuleEdit.vue')

const GiftPutQuery = () => import(/* webpackChunkName: "gift_all" */ '../components/gift/GiftPutQuery.vue')




// 项目管理
//合作方管理
const PartnerList = () => import(/* webpackChunkName: "project_all" */ '../components/project/PartnerList.vue')
//项目配置
const ProjectConfig = () => import(/* webpackChunkName: "project_all" */ '../components/project/ProjectConfig.vue')
//编辑\新增项目
const AddOrEditProject = () => import(/* webpackChunkName: "project_all" */ '../components/project/AddOrEditProject.vue')
//服务管理
const Service = () => import(/* webpackChunkName: "project_all" */ '../components/project/Service.vue')
//新增服务(服务卡)
const ServiceCard = () => import(/* webpackChunkName: "project_all" */ '../components/project/ServiceCard.vue')
//编辑服务(服务卡)
const ServiceCardEdit = () => import(/* webpackChunkName: "project_all" */ '../components/project/ServiceCardEdit.vue')
//新增服务(服务券)
const ServiceCoupon = () => import(/* webpackChunkName: "project_all" */ '../components/project/ServiceCoupon.vue')
//编辑服务
const ServiceCouponEdit = () => import(/* webpackChunkName: "project_all" */ '../components/project/ServiceCouponEdit.vue')
//服务来源配置
const ServiceSource = () => import(/* webpackChunkName: "project_all" */ '../components/project/ServiceSource.vue')
//服务发放查询
const ServiceRecord = () => import(/* webpackChunkName: "project_all" */ '../components/project/ServiceRecord.vue')


const QuestionnaireManage = () => import(/* webpackChunkName: "questionnaire_all" */ '../components/questionnaire/QuestionnaireManage.vue')
const QuestionnaireAdd = () => import(/* webpackChunkName: "questionnaire_all" */ '../components/questionnaire/QuestionnaireAdd.vue')
const QuestionnaireEdit = () => import(/* webpackChunkName: "questionnaire_all" */ '../components/questionnaire/QuestionnaireEdit.vue')
const ReportRecord = () => import(/* webpackChunkName: "questionnaire_all" */ '../components/questionnaire/ReportRecord.vue')

// const Doctor = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/Doctor.vue')
// const Hospital = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/Hospital.vue')
const HospitalServices = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/HospitalServices.vue')
const HospitalServiceAdd = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/ServiceAdd.vue')
const Drugs = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/Drugs.vue')
const DrugsAdd = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/DrugsAdd.vue')
const HospitalManageCofig = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/HospitalManageCofig.vue')
const DrugOrderManage = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/DrugOrderManage.vue')
const DrugOrderDetail = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/DrugOrderDetail.vue')
const PromotionOrderManage = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/PromotionOrderManage.vue')

//医院管理导航
//医生管理
const Doctor = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/Doctor.vue')
//医院管理
const Hospital = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/Hospital.vue')
//新增医院
const AddHospital = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/AddHospital.vue')
//医院详情
const HospitalDetail = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/HospitalDetail.vue')
//员工管理
const Staff = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/Staff.vue')
//新增员工
const AddStaff = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/AddStaff.vue')
//编辑员工
const EditStaff = () => import(/* webpackChunkName: "hospital_all" */ '../components/hospital/EditStaff.vue')

Vue.use(VueRouter)

const routes = [
    { path: '/', redirect: '/login' },
    { path: '/login', component: Login },
    {
        path: '/home',
        component: Home,
        redirect: '/welcome',
        children: [
            { path: '/welcome', component: Welcome },
            { path: '/system/users', component: Users },
            { path: '/product/classification', component: Classification },
            { path: '/product/configure', component: Configure },
            { path: '/product/productAdd', component: ProductAdd },
            { path: '/product/productEdit', component: ProductEdit },
            { path: '/system/rights', component: Rights },
            { path: '/system/roles', component: Roles },
            { path: '/system/accounts', component: Accounts },
            { path: '/system/roleManage', name: 'roleManage', component: RoleManage },
            { path: '/system/logs', component: Logs },
            { path: '/system/ParamConfig', component: ParamConfig },
            { path: '/product/productClassAdd', name: 'ProductClassAdd', component: ProductClassAdd },
            { path: '/product/productClassEdit', name: 'ProductClassEdit', component: ProductClassEdit },
            { path: '/product/source', name: 'source', component: Source },
            { path: '/supplier/product', component: SupplierProduct },
            { path: '/supplier/configure', component: SupplierConfigure },
            { path: '/supplier/supplierProductAdd', component: SupplierProductAdd },
            { path: '/supplier/productDetail', component: ProductDetail },
            { path: '/supplier/supplierAdd', component: SupplierAdd },
            { path: '/supplier/supplierEdit', component: SupplierEdit },
            { path: '/coupon/configureList', component: ConfigureList },
            { path: '/coupon/queryList', component: QueryList },
            { path: '/coupon/grantRecordList', component: GrantRecordList },
            { path: '/coupon/addCoupon', component: AddCoupon },
            { path: '/coupon/editCoupon', component: EditCoupon },
            { path: '/commodity/configureList', component: CommodityConfigureList },
            { path: '/commodity/orderList', component: CommodityOrderList },
            { path: '/commodity/addCommodity', component: AddCommodity },
            { path: '/commodity/commodityDetail', component: CommodityDetail },
            { path: '/commodity/orderDetail', component: CommodityOrderDetail },
            { path: '/commodity/AntiLostCardList', component: AntiLostCardList },
            { path: '/commodity/AntiLostCardDetail', component: AntiLostCardDetail },

            { path: '/pets/UserPets', component: UserPets },
            { path: '/pets/AntiLostCodeManage', component: AntiLostCodeManage },
            { path: '/pets/HotSpotsManage', component: HotSpotsManage },
            { path: '/pets/HotSpotAdd', component: HotSpotAdd },
            { path: '/pets/HotSpotEdit', component: HotSpotEdit },

            { path: '/servicecard/ServicecardConfigure', component: ServicecardConfigure },
            { path: '/servicecard/ServicecardAdd', component: ServicecardAdd },
            { path: '/servicecard/ServicecardEdit', component: ServicecardEdit },
            { path: '/servicecard/QueryList', component: ServicecardQueryList },
            { path: '/servicecard/GrantRecordList', component: ServicecardGrantRecordList },
            { path: '/order/PetHousekeeping', component: PetHousekeeping },
            { path: '/order/PetHousekeepingDetail', component: PetHousekeepingDetail },
            { path: '/order/HealthOrder', component: Healthkeeping },
            { path: '/order/HealthDetail', component: HealthkeepingDetail },

            { path: '/gift/GiftManage', component: GiftManage },
            { path: '/gift/GiftDetail', component: GiftDetail },
            { path: '/gift/GiftBasicInfo', component: GiftBasicInfo },
            { path: '/gift/GiftRuleBasicInfo', component: GiftRuleBasicInfo },
            { path: '/gift/GiftRuleEdit', component: GiftRuleEdit },

            { path: '/gift/AddGift', component: AddGift },
            { path: '/gift/AddGiftRule', component: AddGiftRule },
            { path: '/gift/PriceRuleAdd', component: PriceRuleAdd },
            { path: '/gift/PriceRuleEdit', component: PriceRuleEdit },
            { path: '/gift/GiftPutQuery', component: GiftPutQuery },


            { path: '/project/PartnerList', component: PartnerList },
            { path: '/project/ProjectConfig', component: ProjectConfig },
            { path: '/project/AddOrEditProject', component: AddOrEditProject },
            { path: '/project/Service', component: Service },
            { path: '/project/ServiceCard', component: ServiceCard },
            { path: '/project/ServiceCardEdit', component: ServiceCardEdit },
            { path: '/project/ServiceCoupon', component: ServiceCoupon },
            { path: '/project/ServiceCouponEdit', component: ServiceCouponEdit },
            { path: '/project/ServiceSource', component: ServiceSource },
            { path: '/project/ServiceRecord', component: ServiceRecord },


            { path: '/hospital/Doctor', component: Doctor },
            { path: '/hospital/Hospital', component: Hospital },
            { path: '/hospital/AddHospital', component: AddHospital },
            { path: '/hospital/HospitalDetail', component: HospitalDetail },
            { path: '/hospital/Staff', component: Staff },
            { path: '/hospital/AddStaff', component: AddStaff },
            { path: '/hospital/EditStaff', component: EditStaff },

            { path: '/questionnaire/QuestionnaireManage', component: QuestionnaireManage },
            { path: '/questionnaire/QuestionnaireAdd', component: QuestionnaireAdd },
            { path: '/questionnaire/QuestionnaireEdit', component: QuestionnaireEdit },
            { path: '/questionnaire/ReportRecord', component: ReportRecord },


            { path: '/hospital/HospitalServices', component: HospitalServices },
            { path: '/hospital/ServiceAdd', component: HospitalServiceAdd },
            { path: '/hospital/Drugs', component: Drugs },
            { path: '/hospital/DrugsAdd', component: DrugsAdd },
            { path: '/hospital/HospitalManageCofig', component: HospitalManageCofig },
            { path: '/hospital/DrugOrderManage', component: DrugOrderManage },
            { path: '/hospital/DrugOrderDetail', component: DrugOrderDetail },
            { path: '/hospital/PromotionOrderManage', component: PromotionOrderManage },


        ]
    }
]

const router = new VueRouter({
    routes
})

// 挂载路由导航守卫
router.beforeEach((to, from, next) => {
    // to 将要访问的路径
    // from 代表从哪个路径跳转而来
    // next 是一个函数，表示放行
    // next() 放行 next('/login') 强制跳转

    if (to.path === '/login') return next()
    // 获取token
    const tokenStr = window.sessionStorage.getItem('token')
    if (!tokenStr) return next('/login')
    next()
})

export default router
